﻿using System;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using LTJ.Common;
using LTJ.Web.UI;
using LTJ.FrameWork;
using LTJ.Entity;
using LTJ.Common.Generic;

namespace uswinweb.datacontrol
{
    /// <summary>
    /// 航线信息列表
    /// </summary>
    public partial class RoutBaseList : BaseWebControl
    {
        protected string parpms = LTJ.Common.Utils.UrlDecode(SASRequest.GetString("parms").Trim());
        protected string search_txt_name = SASRequest.GetString("search_txt_name").Trim();
        protected string search_txt_ename = SASRequest.GetString("search_txt_ename").Trim();
        protected string shipcompcode = SASRequest.GetString("shipcompcode");
        protected string pagename = SASRequest.GetString("pagename");
        private string strWhere = "";
        private string orderstr = "";
        protected string action = SASRequest.GetString("action");
        protected string qyg = SASRequest.GetString("qyg");
        protected string mdg = SASRequest.GetString("mdg");
        protected string cs = SASRequest.GetString("cs");
        protected string hx = SASRequest.GetString("hx");
        protected List<RouteBaseInfo> routesTab = new List<RouteBaseInfo>();

        public override void ShowUserControl()
        {
            GetAuth();
            GetComp();
            if (action == "del")
            {
                int msg = RouteBases.DelRouteBase(parpms);
            }
            showdiv = "routbaselistDiv";
            strWhere = RouteBases.GetRouteBaseCondation(compid, 1, qyg, mdg, hx, cs);
            RowsCount = RouteBases.GetRouteBasesCount(strWhere);
            routesTab = RouteBases.GetRouteBaseListByPage(PageIndex, PageSize, strWhere, orderstr);
            if (pagename == "") pagename = SASRequest.GetPageName();
            GetPageList("pagename=" + pagename + "&qyg=" + qyg + "&mdg=" + mdg + "&cs=" + cs + "&hx=" + hx + "&cid=" + compid + "&action=" + action + "&parms=" + parpms);
        }

        public string GetName(string type, string pcode)
        {
            string msg = "&nbsp;";
            string strWhere = " code='" + type.Trim() + "' and tcode='" + pcode.Trim() + "' ";
            BaseDataInfo binfo = BaseDatas.GetBaseDataByStr(strWhere);
            if (binfo != null)
            {
                if (type == "dock")
                {
                    msg = binfo.tcode;
                }
                else
                {
                    msg = binfo.name;
                }
            }
            return msg;
        }
        public string GetMsgStr(string code)
        {
            DataTable bdInfo = new DataTable();
            string msg = "";
            bdInfo = BaseDatas.GetDestportsMsg(" a.code='ports' and a.tcode='" + code + "'");
            if (bdInfo.Rows.Count != 0)
            {
                msg += "所属航线：" + bdInfo.Rows[0]["sshx"].ToString() + "<br/>";
                msg += "所属国家：" + bdInfo.Rows[0]["ssgj"].ToString() + "<br/>";
                msg += "中文名：" + bdInfo.Rows[0]["name"].ToString() + "<br/>";
                msg += "英文名：" + bdInfo.Rows[0]["ename"].ToString() + "<br/>";
            }
            return msg;
        }
    }
}